package com.mzkj.wanjulaile.mobile.api.modules.account.entity;

import com.mzkj.common.utils.DateUtils;
import com.mzkj.common.utils.StringUtils;
import com.mzkj.wanjulaile.mobile.api.common.entity.DataEntity;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

/**
 * 宝宝信息Entity
 *
 * @author ianly
 * @version 2016-10-17
 */
public class Baby extends DataEntity<Baby> {

    private static final long serialVersionUID = 1L;
    private Account account;        // 用户信息
    private String accountId;
    private String nickName;        // 宝宝昵称
    private Integer sex;        // 宝宝性别 0男孩 1女孩
    private String birthday;        // 宝宝出生日期
    private String age;
    private Integer lever;           //宝宝年龄对应玩具年龄段
    private String babyAbility;     //宝宝相应年龄对应锻炼能力

    public Baby() {
        super();
    }

    public Baby(String id) {
        super(id);
    }

    public Baby(String accountId, String nickName, String birthday, Integer sex) {
        this.accountId = accountId;
        this.nickName = nickName;
        this.birthday = birthday;
        this.sex = sex;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Length(min = 1, max = 255, message = "宝宝昵称长度必须介于 1 和 255 之间")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @NotNull(message = "宝宝性别不能为空")
    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    @Length(min = 1, max = 255, message = "宝宝出生日期长度必须介于 1 和 255 之间")
    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getAge() {
        if (StringUtils.isNotEmpty(birthday)) {
            this.age = DateUtils.calAge(birthday);
        } else {
            this.age = "未填写";
        }
        return age;
    }

    public Integer getLever() {
        return lever;
    }

    public void setLever(Integer lever) {
        this.lever = lever;
    }

    public String getBabyAbility() {
        return babyAbility;
    }

    public void setBabyAbility(String babyAbility) {
        this.babyAbility = babyAbility;
    }
}